/**
 * Created by kule on 2017/3/14.
 */
import urlEncode from './urlEncode';
const regUrlSearch=/^([^?]+)($|(\?.*)$)/;

//向url中设置
export const setQuery=function(url,query={}){
    const urlMatch=url.match(regUrlSearch);
    if(!urlMatch){
        return url;
    }
    const baseUrl=urlMatch[1];
    const search=urlMatch[3];

    return baseUrl+'?'+urlEncode(query,search);
};

export default setQuery;